﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chaos.view.powersheet
{
    /// <summary>
    /// Interaction logic for powerslot.xaml
    /// </summary>
    public partial class powerslot : UserControl
    {
        public powerslot()
        {
            InitializeComponent();
        }


        public String Faction
        {
            get
            {
                return (String)GetValue(FactionProperty);
            }
            set
            {
                SetValue(FactionProperty, value);
            }
        }

        public static readonly DependencyProperty FactionProperty =
            DependencyProperty.Register(
                "Faction",
                typeof(String),
                typeof(powerslot),
                new PropertyMetadata(default(String), OnFactionPropertyChanged));

        private static void OnFactionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // AutocompleteTextBox source = d as AutocompleteTextBox; 
            // Do something... 
        } 





        public object Slot
        {
            get
            {
                return slot_control.Content;
            }
            set
            {
                slot_control.Content = value;
            }
        }

        public int Power { get; set; }

        private void powerslot_control_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(view.powersheet.powermarker)))
            {
                view.powersheet.powermarker p = e.Data.GetData(typeof(view.powersheet.powermarker)) as view.powersheet.powermarker;

                if (p.Faction == Faction)
                {
                    network.gameclient c = FindResource("game_client") as network.gameclient;
                    if (c != null)
                    {
                        messages.request_change_powersheet message = new messages.request_change_powersheet();
                        message.Powersheet.Faction = Faction;
                        message.Powersheet.Power = Power;
                        c.sendmessage(message);
                    } 
                }             
            }
        }

        private void powerslot_control_DragOver(object sender, DragEventArgs e)
        {

        }
    }
}
